package com.wealth.scsj.b_app.presenter;

import android.util.Log;

import com.wealth.scsj.b_app.base.GoodsManageBase;
import com.wealth.scsj.b_app.bean.SelectAppClass1Bean;
import com.wealth.scsj.b_app.bean.SelectAppGoodsByStoreAndClassBean;
import com.wealth.scsj.b_app.model.GoodsManageModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 门店运营-展示一级分类
 * 门店运营-商品管理查看分类下的商品presenter
 */

public class GoodsManagePresenter extends BasePresenter implements GoodsManageBase.IPresenter {

    private GoodsManageBase.IModel mModel;
    private GoodsManageBase.IView mView;

    public GoodsManagePresenter(GoodsManageBase.IView view) {
        mView = view;
        mModel = new GoodsManageModel();
    }


    /**
     * 门店运营-展示一级分类
     *
     * @param requestBody
     */
    @Override
    public void deliver1Data(RequestBody requestBody) {
        addSubscription(mModel.get1Data(requestBody, new ResponseCallback<SelectAppClass1Bean>() {
            @Override
            public void onSuccess(SelectAppClass1Bean result) {
                if (result.getStatusCode() == 200) {
                    mView.show1SuccessMsg("获取门店运营一级分类成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("获取门店运营一级分类失败", msg + "");
            }
        }));
    }

    /**
     * 门店运营-商品管理查看分类下的商品
     *
     * @param requestBody
     */
    @Override
    public void deliver2Data(RequestBody requestBody) {
        addSubscription(mModel.get2Data(requestBody, new ResponseCallback<SelectAppGoodsByStoreAndClassBean>() {
            @Override
            public void onSuccess(SelectAppGoodsByStoreAndClassBean result) {
                if (result.getStatusCode() == 200) {
                    mView.show2SuccessMsg("获取门店运营二级分类成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("获取门店运营二级分类失败", msg + "");
            }
        }));
    }

}
